#ifndef ODN_INPUTRECEIVER_H
#define ODN_INPUTRECEIVER_H

//Standard headers
#include <vector>

namespace ouden
{
	namespace input
	{
				
		
		class ODN_InputReceiver
		{
			
		public:
			
			struct Command {
				//Constructors
				Command(int Name) : name(Name), primarykey(0), secondarykey(0) 		{}
				Command(int Name, int PrimaryKey) : name(Name), primarykey(PrimaryKey), secondarykey(0) 		{}
				Command(int Name, int PrimaryKey, int SecondaryKey) : name(Name), primarykey(PrimaryKey), secondarykey(SecondaryKey) 		{}
				
				//Variables
				int name;
				int primarykey;
				int secondarykey;
			};
			
			ODN_InputReceiver();
			virtual ~ODN_InputReceiver()	{}
			
			//Called by input handler every frame 
			void CheckInput(bool keys[256])
			{
				
				//Loop through commands
				for (int i=0;i<commands.size();i++) {
					
					//If the command's primary or secondary key was pressed 
					if (keys[commands[i].primarykey] || keys[commands[i].secondarykey]) {
						
						//Raise the CommandReceived event
						onInputCommand(commands[i].name);
						
					}
					
				}
				
			}
			
			//Called when a key bound to an input command is pressed 
			virtual void onInputCommand(int Name) = 0;
			
			//Creates a new command
			void addInputCommand(int Name, int PrimaryKey, int SecondaryKey = 0)
			{
				Command NewCommand(Name, PrimaryKey, SecondaryKey);
				commands.push_back(NewCommand);	
			}
			
			//Creates a new command and binds key(s) to it
			/*void addAndBindInputCommand(int Name, int PrimaryKey, int SecondaryKey = 0)
			{
				Command NewCommand(Name, PrimaryKey, SecondaryKey);
				commands.push_back(NewCommand);	
			}*/
			
			//Creates a new command and binds a key to it
			void ReBindInputCommand(int Name, int PrimaryKey)
			{
				
				//TODO: 
				//Find command name
				//Set key(s)
				
			}
		
		private:
			
			//Array of commands
			std::vector<Command> commands;
			
		};
		
	} //namespace input
} //namespace ouden

#endif //ODN_INPUTRECEIVER_H
